package com.guigu.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.guigu.pojo.PurchaseInfo;
import com.guigu.pojo.ShopInfo;
import com.guigu.pojo.SupplierSupplyOfGoods;
import com.guigu.service.SupplierSupplyOfGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/supplierSupplyOfGoods/")
public class SupplierSupplyOfGoodsController {
    //自动注入
    @Autowired
    SupplierSupplyOfGoodsService supplierSupplyOfGoodsService;

    //分页查询
    @GetMapping("supplierSupplyOfGoods.action")
    public Page<SupplierSupplyOfGoods> queryAllpage(SupplierSupplyOfGoods supplierSupplyOfGoods,
                                                    @RequestParam(value = "pageno",defaultValue = "1")Integer pageno,
                                                    @RequestParam(value = "pagesize",defaultValue = "5")Integer pagesize){
        return supplierSupplyOfGoodsService.queryAllpage(supplierSupplyOfGoods,pageno,pagesize);
    }

    //根据当前用户，查询供应商目前可以添加到供应商维护商品表的商品
    @GetMapping("Can_be_added_to_supplier_list_data.action")
    public com.guigu.service.utils.Page Can_be_added_to_supplier_list_data(ShopInfo shopInfo,
                                                                           @RequestParam(value = "id")Integer id,
                                                                           @RequestParam(value = "pageno",defaultValue = "1")Integer pageno,
                                                                           @RequestParam(value = "pagesize",defaultValue = "5")Integer pagesize){
        return supplierSupplyOfGoodsService.Can_be_added_to_supplier_list_data(shopInfo,id,pageno,pagesize);
    }

    //添加商品到供应商维护商品表
    @PutMapping("supplierSupplyOfGoods.action")
    public Map add(@RequestBody SupplierSupplyOfGoods supplierSupplyOfGoods){
        return supplierSupplyOfGoodsService.add(supplierSupplyOfGoods);
    }

    //审核供应商维护商品
    @PostMapping("checkSupplierSupplyOfGoods.action")
    public Map checkSupplierSupplyOfGoods(@RequestBody SupplierSupplyOfGoods supplierSupplyOfGoods){
        return  supplierSupplyOfGoodsService.checkSupplierSupplyOfGoods(supplierSupplyOfGoods);
    }

    //获取所有的供应商维护商品表数据
    @GetMapping("queryAllSupplier.action")
    public Page<SupplierSupplyOfGoods> queryAllSupplier(SupplierSupplyOfGoods supplier,
                                                        @RequestParam(value = "pageno",defaultValue = "1")Integer pageno,
                                                        @RequestParam(value = "pagesize",defaultValue = "5")Integer pagesize){
        return supplierSupplyOfGoodsService.queryAllSupplier(supplier,pageno,pagesize);
    }

    //处理总店采购申请【供应商确认发货】
    @PostMapping("supplierDelivery.action")
    public Map supplierDelivery(@RequestBody PurchaseInfo purchaseInfo){
        return  supplierSupplyOfGoodsService.supplierDelivery(purchaseInfo);
    }
    //查询所有供应商供应的商品
    @GetMapping("supplierofgoods.action")
    public Page supplierofgoods(SupplierSupplyOfGoods supplierSupplyOfGoods,
                                Integer loginUserId,
                                @RequestParam(value = "pageno",defaultValue = "1")Integer pageno,
                                @RequestParam(value = "pagesize",defaultValue = "5")Integer pagesize){
        return supplierSupplyOfGoodsService.supplierofgoods(supplierSupplyOfGoods,loginUserId,pageno,pagesize);
    }
    @GetMapping("querybyid.action/{id}")
    public SupplierSupplyOfGoods querybyid(@PathVariable Integer id){
        return supplierSupplyOfGoodsService.querybyid(id);
    }
    //供应商修改供应商品的价格
    @PutMapping("updatebysupplierPrice.action")
    public Map updatebysupplierPrice(@RequestBody SupplierSupplyOfGoods supplierSupplyOfGoods){
        return supplierSupplyOfGoodsService.updatebysupplierPrice(supplierSupplyOfGoods);
    }
    //供应商修改是否上架商品
    @PutMapping("updatebyisDelete.action")
    public Map updatebyisDelete(@RequestBody SupplierSupplyOfGoods supplierSupplyOfGoods){
        return supplierSupplyOfGoodsService.updatebyisDelete(supplierSupplyOfGoods);
    }

    //供应商主页 显示的供应的商品数量  和 正在供应商品的数量 和 停止供应商品的数量
    @GetMapping("queryAllgys.action")
    public List<SupplierSupplyOfGoods> queryAllgys(SupplierSupplyOfGoods supplierSupplyOfGoods){
        return supplierSupplyOfGoodsService.queryAllgys(supplierSupplyOfGoods);
    }
    //供应商主页 显示的供应的商品数量  和 正在供应商品的数量 和 停止供应商品的数量
    @GetMapping("queryAllgys.action")
    public List<SupplierSupplyOfGoods> queryAllgys(SupplierSupplyOfGoods supplierSupplyOfGoods){
        return supplierSupplyOfGoodsService.queryAllgys(supplierSupplyOfGoods);
    }
}
